package com.abel.bigwater.dataserver.model.qdies

import io.netty.buffer.ByteBuf

class MainPulseBaseData : D10BaseData(8) {
    override var type = FuncType.SetPulseBase

    var internalAddr: Byte? = null

    var meterType = PulseMeterType.DualPulse

    var baseRead: Float? = null

    var pulse: PulseType? = null

    var digits: Byte? = null

    override fun fill(buf: ByteBuf) {
        buf.writeByte(internalAddr!!.toInt())
                .writeByte(meterType.code.toInt())
                .writeFloat(baseRead!!)
                .writeByte(pulse!!.code.toInt())
                .writeByte(digits!!.toInt())
    }

    override fun parse(buf: ByteBuf): Boolean {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }

    override fun count(): Int = len
}

/**
 * 脉冲常数 1字节 1： 0.001m3
2： 0.01 m3
3： 0.1 m3
4: 1 m3
 */
enum class PulseType(val code: Byte, val pulse: Float) {
    Liter(1, 0.001F),
    TenLiter(2, 0.01F),
    HundredLiter(3, 0.1F),
    CubMeter(4, 1F)
}

/**
 * 表计类型 1字节 1： 带正反转的双脉冲
2： 单脉冲
3： 双干簧管脉冲
 */
enum class PulseMeterType(val code: Byte) {
    DualPulse(1),
    SinglePulse(2),
    DualPipe(3)
}
